package com.cy.shiro;

import com.cy.model.Account;
import com.cy.model.User;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 权限验证的一个用户对象,记录在缓存中.
 */
public class ShiroUser implements Serializable {

    private static final long serialVersionUID = -3495087486618632534L;

    private Long id;
    private String name;
    private List<String> rolesKey;
    private List<String> roles;
    private Integer type ;
    private Object user;

    public ShiroUser(Account user) {
        this.id = user.getAccountId();
        this.name = user.getName();
        this.roles = new ArrayList<>();
        this.rolesKey = new ArrayList<>();
        this.user = user;
        this.type = 1;
    }

    public ShiroUser(User user) {
        this.id = user.getUserId();
        this.name = user.getNickName();
        this.roles = new ArrayList<>();
        this.rolesKey = new ArrayList<>();
        this.user = user;
        this.type = 0;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public List<String> getRolesKey() {
        return rolesKey;
    }

    public void setRolesKey(List<String> rolesKey) {
        this.rolesKey = rolesKey;
    }

    public List<String> getRoles() {
        return roles;
    }

    public void setRoles(List<String> roles) {
        this.roles = roles;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Object getUser() {
        return user;
    }

    public void setUser(Object user) {
        this.user = user;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
